/**
 * Author:runlin。tang.
 * Creation Time: 2016/6/29
 * Description:
 *             页面需要获取路由的mac 和sn数据页面
 */
define(['jquery','underscore','backbone','../../../common/js/lib/text!../../../tpl/getData.tpl','../m/binding','../v/successBind','../m/getDatas'],
    function ($,_,Backbone,getData,binding,successBind,getDatas) {
    function indexV(data){
        var html = '';
        var sn = '';
        var mac = '';
        var nuller = 0;
        if(data.data.route_sn != null){
            sn = '<span class="getsn">'+data.data.route_sn+'</span>';
        }else{
            sn = '<span class="getsn">未知</span>';
            nuller = nuller+1;
        }
        if(data.data.route_mac != null){
            mac = '<span class="getmac">'+data.data.route_mac+'</span>';
        }else{
            mac = '<span class="getmac">未知</span>';
            nuller = nuller+1;
        }
        var htmlser = '';
        var binds = '';

        if(nuller>0){

            htmlser = '<div class="ly-tip fail-tip"><i></i><span>绑定失败，请重新绑定</span></div>';
            binds = '<div class="com_btn" style="margin-top:1rem;"><a href="javascript:;" class="two-binding">重新绑定</a></div>'
        }else{

            binds = '<div class="com_btn" style="margin-top:1rem;"><a href="javascript:;" class="one-binding">一键绑定</a></div>'
        }


        html +='<div class="contect-tap"><img src="images/router/ic_navigation_two.png" alt=""></div>';
        html +='<div class="success-txt"><i>门店名称</i><a href="'+serUrl+'" class="getshopname">'+shopName+'</a></div>';
        html +='<ul class="success-txt">';
        html +='<li><i>SN序列号</i>'+sn+'</li>';
        html +='<li><i>MAC地址</i>'+mac+'</li>';
        html +='</ul>'+htmlser+binds;


        $('.webApp-content').html(html);
        $('.webApp-content').on('click','.one-binding',function(){
            binding(data.data.route_sn,data.data.route_mac);
        });
        //重新绑定
        $('.webApp-content').on('click','.two-binding',function(){
            getDatas();
        });
        $('.webApp-content').on('click','.success-binding',function(){
            successBind();
        });
    }

    return indexV;
});